package communication.common.business.base;

import lombok.Getter;
import lombok.ToString;

import java.util.Arrays;

/**
 * 操作系统类型
 * @author mac
 */

@Getter
@ToString
public enum OsTypeEnum {

    /**
     *  mac os
     */
    MAC_OS("Mac",0),

    /**
     * linx
     */
    LINUX("Linux",1),

    /**
     * win 10
     */
    WIN_10("Windows",2);



    private String name;

    private int value;

    /**
     * 构造
     * @param name 操作系统的名称
     * @param value 类型值
     */
    private OsTypeEnum(String name,int value){
        this.name=name;
        this.value=value;
    }

    public static OsTypeEnum getByName(String name) throws Exception {
        return Arrays.stream(OsTypeEnum.values()).filter(e->name.contains(e.name))
                .findFirst()
                .orElseThrow(()-> new Exception("unknown os system : "+name+" !"));
    }
}
